package cn.tramy.pinxian.wind.domain

import cn.tramy.pinxian.wind.domain.model.BaseDomainModel

class DomainModelHolder {
    private val models: MutableList<BaseDomainModel> = mutableListOf()

    companion object {
        private val localHolder: ThreadLocal<DomainModelHolder> = ThreadLocal.withInitial { DomainModelHolder() }
        fun current() = localHolder.get()
    }

    fun addDomainModel(model: BaseDomainModel) {
        this.models.add(model)
    }

    fun domainModels(): List<BaseDomainModel> = models.toList()

    fun reset() = this.models.clear()
}